<?php

class Silk_Zgb_Block_Renderer_Delivered extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
    /**
     * @param Varien_Object $row
     * @return mixed
     */
    public function render(Varien_Object $row)
    {
        $shipping_id = $row->getId();
        /** @var Silk_Tms_Model_Mysql4_Shipping_Order_Collection $collection */
        $collection = Mage::getModel('tms/shipping_order')->getCollection();
        $orders = $collection->addFieldToFilter('shipping_id', $shipping_id)
            ->addFieldToFilter('status', Silk_Tms_Helper_Status::STATUS_SHIPPING_DELIVERED);

        return count($orders) ?: '0';
    }
}